using I2.Loc;
using UnityEngine;

public class MapControl : MonoBehaviour
{
	public Vector3 worldPosition;

	public string sceneName;

	public GameObject locked;

	public GameObject repuatationBar;

	public UITexture icon;

	public GameObject battle;

	public UISprite greenProgress;

	public UISprite blueProgress;

	public UILabel districtName;

	public UILabel getLevel;

	public MapControlManager master;

	public bool Visible
	{
		get
		{
			return base.gameObject.activeSelf;
		}
		set
		{
			base.gameObject.SetActive(value);
		}
	}

	private void Awake()
	{
		battle.SetActive(false);
	}

	private void OnEnable()
	{
		districtName.text = ScriptLocalization.Get("PVP_map_info/" + sceneName);
	}

	public void UpdatePosition(Vector2 pos)
	{
		base.transform.localPosition = new Vector3(pos.x, pos.y, 0f);
	}

	public void SetInfo(ReputationMapInfo info)
	{
		if (info.state == DistrictState.Locked)
		{
			locked.SetActive(true);
			repuatationBar.SetActive(false);
			icon.gameObject.SetActive(false);
			districtName.gameObject.SetActive(false);
			if (info.elite)
			{
				getLevel.text = LocalizationManager.GetTermTranslation("PVP_map_info/elite_locked_get") + info.needCaptureToUnlock;
			}
			else
			{
				getLevel.text = LocalizationManager.GetTermTranslation("PVP_map_info/get_level") + info.requiredLevel;
			}
			return;
		}
		locked.SetActive(false);
		repuatationBar.SetActive(true);
		icon.gameObject.SetActive(true);
		float fillAmount = info.curReputation / info.maxReputation;
		if (info.state == DistrictState.Captured)
		{
			blueProgress.gameObject.SetActive(false);
			greenProgress.gameObject.SetActive(true);
			districtName.gameObject.SetActive(true);
			greenProgress.fillAmount = fillAmount;
		}
		else
		{
			greenProgress.gameObject.SetActive(false);
			blueProgress.gameObject.SetActive(true);
			blueProgress.fillAmount = fillAmount;
		}
	}

	public void GoGame()
	{
		SceneLoadBar.showHalfBar = false;
		MessageWindow.instance.SetVisiblePanelLoading(true, string.Empty);
		controllerConnectPhoton.thisScript.chooseNameLevel = sceneName;
		controllerConnectPhoton.thisScript.changeMap = true;
		PhotonNetwork.LeaveRoom();
	}

	public void ShowBattleButton()
	{
		battle.SetActive(false);
	}

	public void HideBattle()
	{
		battle.SetActive(false);
	}
}
